package com.caishi.lkx.user.service.impl;

import com.caishi.lkx.user.mapper.ActionMapper;
import com.caishi.lkx.user.model.ActionModel;
import com.caishi.lkx.user.model.re.ActionRoleReModel;
import com.caishi.lkx.user.service.IActionService;
import com.zzw.common.Wrappers;
import com.zzw.common.entity.IBSDUMapper;

import com.caishi.lkx.user.mapper.re.ActionRoleReMapper;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author by keray
 * date:2021/4/13 9:39 上午
 */
@Service
public class ActionServiceImpl implements IActionService {

    @Resource
    private ActionMapper actionMapper;

    @Resource
    private ActionRoleReMapper actionRoleReMapper;

    @Override
    public IBSDUMapper<ActionModel, String> getMapper() {
        return actionMapper;
    }

    @Override
    public Boolean canDelete(List<String> keys) {
        return actionRoleReMapper.selectCount(Wrappers.lambdaQuery(new ActionRoleReModel())
                .in(keys.size() > 1, ActionRoleReModel::getActionCode, keys)
                .eq(keys.size() == 1, ActionRoleReModel::getActionCode, keys.get(0))
        ) == 0;
    }
}
